home *** CD-ROM | disk | FTP | other *** search
/ IRIX Installation Tools & Overlays 2002 November / SGI IRIX Installation Tools & Overlays 2002 November - Disc 4.iso / dist / motif21_dev.idb / usr / Motif-2.1 / include / Xm / SgiP.h.z / SgiP.h
C/C++ Source or Header  |  2002-10-15  |  8KB  |  241 lines

  1. /* Definitions for SGI widget extensions */
  2.  
  3. #ifndef _SgiP_h
  4. #define _SgiP_h
  5.  
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9.  
  10. #ifdef XM_LIBRARY_BUILD /* SGI upgrade for 64-bits */
  11. /*
  12.  * strlen() -- Xm strings are never more than 32 bits, so this definition
  13.  *      does not hurt.  It does prevent "implicit conversion from "unsigned
  14.  *      long" to ..." warnings.
  15.  *
  16.  * sizeof() -- Ditto for "sizeof".
  17.  *
  18.  * XtMalloc() -- We have no need to XtMalloc more than 32 bits worth.
  19.  *
  20.  * Doing this sort of thing is a really ugly kludge to get rid of a lot
  21.  * of compiler warnings in just this one place.  The real problem is that
  22.  * XtMalloc & friends are busted -- they should take size_t sizes, justg as
  23.  * underlying routines they wrap do.  Once that happens, these defines
  24.  * should be removed.  Also those in the Mrm and uil directories.
  25.  */
  26. #  define strlen(s) ((unsigned int)strlen(s))
  27. #  define sizeof(s) ((unsigned int)sizeof(s))
  28. #  define XtMalloc(s) (XtMalloc((Cardinal)(s)))
  29. #  define XtCalloc(n,s) (XtCalloc((n),(Cardinal)(s)))
  30. #  define XtRealloc(p,n) (XtRealloc((p),(Cardinal)(n)))
  31.  
  32. /*
  33.  * Motif has a number of implicit conversions that risk losing data.
  34.  * Probably the most troublesome are long-to-int type conversions, because
  35.  * in a 64 bit (but not a 32-bit) environment the upper 32 bits are thrown
  36.  * away.  This creates a bug that will work OK on a little-endian machine,
  37.  * but fail on a MIPS machine.  We have really found such a bug in libMrm,
  38.  * and there is other code where it would be very difficult to check by
  39.  * hand whether that could ever occur.  Therefore, we make a ASSERT to
  40.  * catch such stuff.
  41.  *
  42.  * This assertion will pass all good data.  It will fail to catch some bad
  43.  * data.  Probably close enough for catching porting mistakes, though.
  44.  */
  45. #  if (_MIPS_SZLONG == 64)
  46. #    include <assert.h>
  47. #    define SGI_ASSERT_NO_TRUNC(val) assert( (((val) & 0xFFFFFFFF00000000) == 0) || (((val) & 0xFFFFFFFF00000000) == 0xFFFFFFFF00000000) )
  48. #  else
  49. #    define SGI_ASSERT_NO_TRUNC(val)
  50. #  endif /* _MIPS_SZLONG */
  51.  
  52. #endif /* XM_LIBRARY_BUILD */
  53.         
  54. /* Global Variables declared */
  55. extern int sgIsWindowManager;        /* Only set by mwm */
  56. extern int SGImode;    /* So it is resolved for apps linked with libChow */
  57. /* unique contexts used for reference counting in _SG_XtSetValues(): */
  58. extern XContext SGIrefCntContext;    /* context for the reference count */
  59. extern XContext SGIsetValuesFcnContext;    /* context for the saved fcn */
  60.  
  61. /*
  62.  * SGI has added a vendor extension pointer to all widget class and instance
  63.  * records.  That helps to preserve compatible shared libraries and widget
  64.  * subclasses.
  65.  *
  66.  * The following is an SGI class extension record.  Any class that needs
  67.  * one will have one.  The record supports automatic intialization of SGI
  68.  * sub-resources.  Therefore, it is the same for all widgets.
  69.  *
  70.  * The instance extension record is specific to each widget that needs one,
  71.  * so it is declared in corresponding the <Widget>P.h file.
  72.  */
  73.  
  74. #define _SgExtensionRecVersion    1L
  75. typedef struct _sgClassExtensionRec {
  76.     long        version;    /* Version, for future compatibility control */
  77.     Cardinal    isize;    /* Size of the instance extension record */
  78.     XtResource *rsrc_ptr;    /* Ptr to the resources data definition */
  79.     int        rsrc_num;    /* Number of resources */
  80. } _SgClassExtensionRec, *_SgClassExtension;
  81.  
  82. #define _SgInstanceExtensionRecVersion    1L
  83. typedef struct _sgInstanceExtensionRec {
  84.     long        version;    /* Version, for future compatibility control */
  85.     /* OK to add extra fields as they become necessary. */
  86.     /* Instance resource data starts here, after the common fields. */
  87. } _SgInstanceExtensionRec, *_SgInstanceExtension;
  88.  
  89.  
  90. /*******************************************************************************
  91.  *
  92.  * Definitions for the SGI "shader" -- i.e. picking different shades of the
  93.  * same color to get SGI-standard visual effects.
  94.  */
  95.  
  96. typedef struct _shader {
  97.     Display *dpy;
  98.     Colormap cmap;
  99.     Cardinal depth;
  100.     Pixel    pixel;
  101.     short    r,g,b;
  102.     int      faceShade; /* point along the shade line where bkg color falls */
  103.     GC       GCarray[9]; /* GCs for different shades of the base color*/
  104.     struct _shader* next;
  105. }*shaderptr;
  106.  
  107. /* indices to access GCs from a shader */
  108. #  define tuShader_darkest   0
  109. #  define tuShader_veryDark  1
  110. #  define tuShader_dark      2
  111. #  define tuShader_medium    3
  112. #  define tuShader_light     4
  113. #  define tuShader_veryLight 5
  114. #  define tuShader_lightest  6
  115. #  define tuShader_white     7
  116.  
  117. /* definitions for brighter and darker to be used for _sgAllocClosestColor */
  118. #  define _SG_ANY_BRIGHTNESS     0
  119. #  define _SG_BRIGHTER         1
  120. #  define _SG_DARKER        -1
  121.  
  122.  
  123. /********    Function Declarations Used From Widgets    ********/
  124. #ifdef _NO_PROTO
  125.  
  126.     extern XtPointer _SG_GetResourcePtr()    ;
  127.     extern GC _sgFindGC()            ;
  128.     extern void _sgFindShader()            ;
  129.     Status _sgAllocClosestColor()    ;
  130.  
  131. #else
  132.  
  133.     extern XtPointer _SG_GetResourcePtr(
  134.             Widget       w        ,
  135.             WidgetClass  wc)    ;
  136.     extern GC _sgFindGC(Widget w, shaderptr shader1,int index);
  137.     extern void _sgFindShader(Widget w, shaderptr* return_adr,Pixel p);
  138.     Status _sgAllocClosestColor(Display *display, Screen *screen, Colormap cmap, XColor *cdef, int direction, XColor *cantbe);
  139.  
  140. #endif /* _NO_PROTO */
  141. /********    End Function Declarations Used From Widgets    ********/
  142.  
  143.  
  144.  
  145. /********    Private Function Declarations    ********/
  146. #ifdef _NO_PROTO
  147.  
  148.     extern void    _SG_ClassPartInitialize()    ;
  149.     extern void    _SG_XtInitialize()           ;
  150.     extern void    _SG_XtDestroyPrehook()    ;
  151.     extern void    _SG_XtDestroyPosthook()    ;
  152.     extern void    _SG_XtGetValuesHook()    ;
  153.     extern Boolean _SG_XtSetValues()        ;
  154.     extern int     _XmBrightness()         ; /* Sgi made this visible */
  155.  
  156. #else
  157.  
  158.     extern void _SG_ClassPartInitialize(void)    ;
  159.  
  160.     extern void _SG_XtInitialize(
  161.                 Widget       req    ,
  162.                 Widget       new_w    ,
  163.                 ArgList      args    ,
  164.                 Cardinal    *num_args)    ;
  165.  
  166.     extern void _SG_XtDestroyPrehook(
  167.             Widget       w)        ;
  168.  
  169.     extern void _SG_XtDestroyPosthook(
  170.             Widget       w)        ;
  171.  
  172.     extern void _SG_XtGetValuesHook(
  173.             Widget       new_w    ,
  174.             ArgList      args    ,
  175.             Cardinal    *num_args)    ;
  176.  
  177.     extern Boolean _SG_XtSetValues(
  178.             Widget       current    ,
  179.             Widget       req    ,
  180.             Widget       new_w    ,
  181.             ArgList      args    ,
  182.             Cardinal    *num_args)    ;
  183.     extern int _XmBrightness(            /* Sgi made this visible */
  184.             XColor        *color)    ;
  185.  
  186. #endif /* _NO_PROTO */
  187. /********    End Private Function Declarations    ********/
  188.  
  189.  
  190. #if 0
  191. /*
  192.  * The following declare NOP routines are for libXm, so that Chow-ized
  193.  * code can be linked with libXm.  The expectation is that the code will
  194.  * never call these routines at run time.  The actual functions are
  195.  * declared in Sgi.c.
  196.  */
  197. #if !(defined sgiLibChow && sgiLibChow)
  198. #ifdef _NO_PROTO
  199. extern void __SGI_RenderShadows();
  200. #else
  201.  
  202. extern void _SGI_RenderShadows(Widget w ,Display* dpy,Drawable d,
  203.                                shaderptr shader,Position x, Position y,
  204.                                Dimension width,Dimension height,
  205.                                int* state_array,
  206.                                int shadow_thickness,
  207.                                unsigned int shadow_style);
  208.  
  209. #endif  /* _NO_PROTO */
  210. #endif  /* !(defined sgiLibChow && sgiLibChow) */
  211. #endif  /* 0 */
  212.  
  213.  
  214. /* This was called _XmOSGetQualifiedDir() in Motif 1.2.
  215.  * Renaming it to emphasize SGI-added feature.  It is used
  216.  * by SgFSB.c
  217.  */
  218. extern String _SgOSGetQualifiedDir(String dirSpec);
  219.  
  220. /* same as XmeGetDefaultRenderTable, except returns new fontList
  221.  * instead of (not thread safe) pointer to static memory
  222.  * caller must free the fontList!!!
  223.  * code is in ResConvert.c
  224.  */
  225. extern XmFontList
  226. _SgXmeGetDefaultRenderTable(
  227.         Widget w,
  228. #if NeedWidePrototypes
  229.         unsigned int fontListType );
  230. #else
  231.         unsigned char fontListType );
  232. #endif /* NeedWidePrototypes */
  233.  
  234. #ifdef __cplusplus
  235. }  /* Close scope of 'extern "C"' declaration which encloses file. */
  236. #endif
  237.  
  238. #endif /* _SgiP_h */
  239. /* DON'T ADD STUFF AFTER THIS #endif */
  240.  
  241.